using UnityEngine;

public class BattleAttack_Siplett_Icecube : MonoBehaviour
{
	[SerializeField]
	private AnimationCurve fallSpeedCurve;

	[SerializeField]
	private float curveDuration = 3f;

	[SerializeField]
	private Sprite[] PossibleIceSprites;

	[SerializeField]
	private Sprite RareIceeIcecube;

	[SerializeField]
	private float iceRotateRange = 3f;

	[SerializeField]
	private GameObject Prefab_Kaplunk;

	[SerializeField]
	private SpriteRenderer thisRenderer;

	[SerializeField]
	private AudioClip KaplunkSFX;

	private float elapsedTime;

	private void Awake()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		int num = Random.Range(0, 100);
		MonoBehaviour.print((object)("Dice Equal = " + num));
		if (num == 66)
		{
			thisRenderer.sprite = RareIceeIcecube;
		}
		else
		{
			thisRenderer.sprite = PossibleIceSprites[Random.Range(0, PossibleIceSprites.Length)];
		}
		((Component)this).transform.rotation = Quaternion.Euler(0f, 0f, (float)Random.Range(0, 360));
		iceRotateRange = Random.Range(0f - iceRotateRange, iceRotateRange);
		if (Random.Range(0, 2) == 0)
		{
			thisRenderer.flipX = true;
		}
		if (Random.Range(0, 2) == 0)
		{
			thisRenderer.flipY = true;
		}
	}

	private void Start()
	{
		CutsceneUtils.FadeInSprite(thisRenderer);
	}

	private void Update()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		elapsedTime += Time.deltaTime;
		float num = fallSpeedCurve.Evaluate(elapsedTime / curveDuration);
		((Component)this).transform.position = Vector2.op_Implicit(new Vector2(((Component)this).transform.position.x, ((Component)this).transform.position.y - num * Time.deltaTime));
		Transform transform = ((Component)this).transform;
		Quaternion rotation = ((Component)this).transform.rotation;
		transform.rotation = Quaternion.Euler(0f, 0f, ((Quaternion)(ref rotation)).eulerAngles.z + iceRotateRange * Time.deltaTime);
		if ((Object)(object)BattleAttack_Siplett_Kaplunk.instance != (Object)null && ((Component)this).transform.position.y < ((Component)BattleAttack_Siplett_Kaplunk.instance.LiquidBack_Renderer).transform.position.y)
		{
			Object.Instantiate<GameObject>(Prefab_Kaplunk, BattleSystem.Instance.Holder_Bullets.transform).transform.position = ((Component)this).transform.position;
			BattleSystem.PlayBattleSoundEffect(KaplunkSFX, 1f, Random.Range(0.85f, 1.15f));
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		if (elapsedTime > curveDuration)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
